<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">


<f:metadata>  
    <f:viewParam name="idpacchetto" value="#{carrelloPresBean.pacchettoInCarrello.pacchettoOriginale.descrizione}" />  
</f:metadata>


<h:head>
<h:outputStylesheet library="css" name="default.css" target="head" />
	<title> #{carrelloPresBean.pacchettoInCarrello.prenotazione}</title>
</h:head>
<h:body >
#{carrelloPresBean.onLoadFormDettagliCarrello()}

<h:form>
<p:toolbar style="heigh:35px; margin-bottom:25px" id="tb">
		<p:toolbarGroup align="left" style="margin-top:5px; margin-left:10px" id="tools">
		Utente #{userBean.name} <p:separator/> #{userBean.mail}
		
		</p:toolbarGroup>
		<p:toolbarGroup align="right">	
		<p:button value="Indietro" outcome="show_carrello.xhtml" icon="ui-icon-carat-1-w" />	
			<p:menuButton value="Opzioni">
					<p:menuitem value="Home" url="index.xhtml" icon="ui-icon-home" />
					<p:menuitem value="Visualizza Carrello" outcome="show_carrello.xhtml" icon="ui-icon-cart" />
					<p:menuitem value="Mostra Prenotazioni" outcome="show_prenotati.xhtml" icon="ui-icon-tag" />
					<p:menuitem value="Visualizza Pacchetti" outcome="show_pacchetti.xhtml" icon="ui-icon-suitcase" />
			</p:menuButton>
		<p:separator/>
		<p:commandButton action="#{logBean.logout}" value="Logout" icon="ui-icon-power" />
		</p:toolbarGroup>
	</p:toolbar>
	<p:sticky target="tb" />
	</h:form>
	
<h:form id="form">
				 <p:growl id="growl" showDetail="true" sticky="true" />  
				 <h:outputText id="modelID" value="#{carrelloPresBean.pacchettoInCarrello.IDPacchetto}" /><br></br> 
                <h:outputText id="modelNome" value="#{carrelloPresBean.pacchettoInCarrello.pacchettoOriginale.nome}" /><br></br> 
                <h:outputText id="modelNo" value="#{carrelloPresBean.pacchettoInCarrello.pacchettoOriginale.descrizione}" /> 
                
                
                <p:dataTable id="Hotel" var="pkHotel" value="#{carrelloPresBean.pacchettoInCarrello.hotels}" editable="true" editMode="cell"  >  
       
			        <p:column headerText="ID">
			            <h:outputText value="#{pkHotel.hotel.ID}" />
			        </p:column>
			        <p:column headerText="nome">  
			            <h:outputText value="#{pkHotel.hotel.nome}" />
			        </p:column>
			         <p:column headerText="Loc">  
			            <h:outputText value="#{pkHotel.hotel.localita.nome}" /> 
			        </p:column>  
			        <p:column headerText="Numero Persone">
				        <p:cellEditor>
			                <f:facet name="output"><h:outputText value="#{pkHotel.numeroPersone}" /></f:facet>
			                <f:facet name="input"><p:inputText value="#{pkHotel.numeroPersone}" style="width:96%" /></f:facet>
			            </p:cellEditor>
			        </p:column>
			        <p:column headerText="Data CheckIN">
			        <p:calendar value="#{pkHotel.checkIN}" showButtonPanel="true"/>
			        </p:column>
			        <p:column headerText="Data CheckOUT">
			        	<p:calendar value="#{pkHotel.checkOUT}" showButtonPanel="true"/>
			        </p:column>
			        <p:column headerText="Pagato da">  
			            <h:outputText value="#{pkHotel.giftList.pagante.nome}" />
			        </p:column>
			        <p:column >
			        	 <p:commandButton value="Delete" action="#{carrelloPresBean.delete}" update=":form:Hotel">
			        			<f:setPropertyActionListener value="#{pkHotel}" target="#{carrelloPresBean.cancellaHotel}" />
			        	</p:commandButton> 
			        </p:column>
			         <p:column >
			        	 <p:commandButton value="Aggiungi a GiftList" action="#{carrelloPresBean.addGiftList}" update=":form:growl">
			        			<f:setPropertyActionListener value="#{pkHotel}" target="#{carrelloPresBean.cancellaHotel}" />
			        	</p:commandButton> 
			        </p:column>
			    </p:dataTable>
			   
				 <br/><br/>

			    <!-- Per il TOUR!!! -->
			     <p:dataTable id="Tour" var="pkTour" value="#{carrelloPresBean.pacchettoInCarrello.tours}" editable="true" editMode="cell"  >  
                          
			        <p:column headerText="ID">  
			            <h:outputText value="#{pkTour.tour.ID}" />  
			        </p:column>  
			        <p:column headerText="nome">  
			            <h:outputText value="#{pkTour.tour.descrizione}" />  
			        </p:column>   
			         <p:column headerText="Numero Persone">
				        <p:cellEditor>
			                <f:facet name="output"><h:outputText value="#{pkTour.numeroPersone}" /></f:facet>
			                <f:facet name="input"><p:inputText value="#{pkTour.numeroPersone}" style="width:96%" /></f:facet>
			            </p:cellEditor>
			        </p:column>
			         
			        <p:column headerText="Data ">
			        <p:calendar value="#{pkTour.data}" showButtonPanel="true"/>  
			        </p:column>
			         <p:column headerText="Pagato da">  
			            <h:outputText value="#{pkTour.giftList.pagante.nome}" />
			        </p:column>
			        <p:column >
			        	 <p:commandButton value="Delete" action="#{carrelloPresBean.deleteTour}" update=":form:Tour">
			        			<f:setPropertyActionListener value="#{pkTour}" target="#{carrelloPresBean.cancellaTour}" />
			        	</p:commandButton>  
			        </p:column>
			        <p:column >
			        	 <p:commandButton value="Aggiungi a GiftList" action="#{carrelloPresBean.addGiftListTour}" update=":form:growl">
			        			<f:setPropertyActionListener value="#{pkTour}" target="#{carrelloPresBean.cancellaTour}" />
			        	</p:commandButton> 
			        </p:column>
			    </p:dataTable> 
			   
				<br/><br/>
			    
			    <!-- Per il Volo!!! -->
			     <p:dataTable id="Volo" var="pkVolo" value="#{carrelloPresBean.pacchettoInCarrello.voli}" editable="true" editMode="cell">  
             
			        <p:column headerText="Da aeroporto">  
			            <h:outputText value="#{pkVolo.trattaVolo.daAeroporto.name}" />  
			        </p:column>  
			        <p:column headerText="A aeroporto">  
			            <h:outputText value="#{pkVolo.trattaVolo.aAeroporto.name}" />  
			        </p:column>    
			        <p:column headerText="A aeroporto">  
			            <h:outputText value="#{pkVolo.trattaVolo.compagnia.nome}" />  
			        </p:column>  
			        <p:column headerText="numero persone">
			        <!-- non riesce a modificare il numero di persone -->
				        <p:cellEditor>  
			                <f:facet name="output"><h:outputText value="#{pkVolo.numeroPersone}" /></f:facet>  
			                <f:facet name="input"><p:inputText value="#{pkVolo.numeroPersone}" style="width:96%" id="numPersoneVolo" label="NPersoneTour"/></f:facet>  
			            </p:cellEditor>  
			        </p:column>
			        <p:column headerText="Data ">
			        <p:calendar value="#{pkVolo.data}" showButtonPanel="true"/>  
			        </p:column>
			         <p:column headerText="Pagato da">  
			            <h:outputText value="#{pkVolo.giftList.pagante.nome}" />
			        </p:column>
			        <p:column >
			        	 <p:commandButton value="Delete" action="#{carrelloPresBean.deleteAeroporto}" update=":form:Volo">
			        			<f:setPropertyActionListener value="#{pkVolo}" target="#{carrelloPresBean.cancellaVolo}" />
			        	</p:commandButton>  
			        </p:column>
			         <p:column >
			        	 <p:commandButton value="Aggiungi a GiftList" action="#{carrelloPresBean.addGiftListVolo}" update=":form:growl">
			        			<f:setPropertyActionListener value="#{pkVolo}" target="#{carrelloPresBean.cancellaVolo}" />
			        	</p:commandButton> 
			        </p:column>
			    </p:dataTable> 
			    
			     <!-- Aggiungi Nuovi elementi -->
				<p:accordionPanel>  
   						
			    
   						<p:tab title="Aggiungi Hotel">
						   <p:dataTable var="hotel" value="#{carrelloPresBean.allHotel}" rowKey="#{hotel.ID}" paginator="true" rows="10"  
			                 selection="#{carrelloPresBean.aggiungiHotel}" selectionMode="single" filteredValue="#{carrelloPresBean.filteredHotel}" id="HotelTableID1" >  

						        <f:facet name="header">
						            List of Hotels
						            <p:commandButton value="Aggiungi a lista" action="#{carrelloPresBean.aggiungiHotel}" update=":form:Hotel" ></p:commandButton>
						        </f:facet>
						  
						        <p:column headerText="Nome" sortBy="nome" filterBy="nome" id="nome">  
						            #{hotel.nome}
						        </p:column>
						        
						        <p:column headerText="Stato" sortBy="localita.stato" filterBy="localita.stato" id="statoHotel">  
						            #{hotel.localita.stato}
						        </p:column>
						  
						        <p:column headerText="Città" sortBy="localita.nome" filterBy="localita.nome" id="cittaHotel">  
						            #{hotel.localita.nome}
						        </p:column>
						  
						        <p:column headerText="Via" sortBy="via" filterBy="via" id="via">  
						            #{hotel.via}
						        </p:column>
			    		</p:dataTable>
			    	</p:tab>
			  
			     <p:tab title="Aggiungi Volo"> 
						   <p:dataTable var="volo" value="#{carrelloPresBean.allVoli}" rowKey="#{volo.ID}" paginator="true" rows="10"  
			                 selection="#{carrelloPresBean.aggiungivolo}" selectionMode="single" filteredValue="#{carrelloPresBean.filteredVoli}" id="AllVoliTable" >  

						        <f:facet name="header">  
						            List of Voli
						            <p:commandButton value="Aggiungi a lista" action="#{carrelloPresBean.aggiungiVolo}" update=":form:Volo" ></p:commandButton>
						        </f:facet>  
						  
						        <p:column headerText="Da aeroporto" sortBy="daAeroporto.name" filterBy="daAeroporto.name" id="aAeroportoall">  
						            #{volo.daAeroporto.name}  
						        </p:column>  
						        
						         <p:column headerText="Da aeroporto" sortBy="aAeroporto.name" filterBy="aAeroporto.name" id="daAeroportoall">  
						            #{volo.aAeroporto.name}  
						        </p:column> 
						        
						        <p:column headerText="Compagnia" sortBy="compagnia.nome" filterBy="compagnia.nome" id="compagniaall">  
						            #{volo.compagnia.nome}  
						        </p:column>
   
			    		</p:dataTable>  
			    	</p:tab>
   						<p:tab title="Aggiungi Tour"> 
						   <p:dataTable var="tour" value="#{carrelloPresBean.allTour}" rowKey="#{tour.ID}" paginator="true" rows="10"  
			                 selection="#{carrelloPresBean.aggiungiTour}" selectionMode="single" filteredValue="#{carrelloPresBean.filteredTour}" id="AllTourTable" >  

						        <f:facet name="header">  
						            List of Tour
						            <p:commandButton value="Aggiungi a lista" action="#{carrelloPresBean.aggiungiTour}" update=":form:Tour" ></p:commandButton>
						        </f:facet>  
						  
						        <p:column headerText="Descrizione" sortBy="descrizione" filterBy="descrizione" id="nomeTour">  
						            #{tour.descrizione}  
						        </p:column>  
						        
						        <p:column headerText="Stato" sortBy="localita.stato" filterBy="localita.stato" id="statoTour">  
						            #{tour.localita.stato}  
						        </p:column>
						  
						        <p:column headerText="Città" sortBy="localita.nome" filterBy="localita.nome" id="cittaTour">  
						            #{tour.localita.nome}  
						        </p:column>  
						   
			    		</p:dataTable>  
			    	</p:tab>
			 
			    </p:accordionPanel>  
			    <p:commandButton value="Salva modifiche" action="#{carrelloPresBean.modificaCarrello}" type="submit"></p:commandButton>
			    <p:commandButton value="Prenota" action="#{carrelloPresBean.Prenota}" type="submit"></p:commandButton>
				<!-- <p:commandButton value="" action="#{carrelloPresBean.modificaCarrello()}" type="submit"></p:commandButton> -->
</h:form>
</h:body>
</html>